package fmi.chesstern.controller.implementation;


import fmi.chesstern.controller.GameCommandExecutor;
import fmi.chesstern.controller.GameCommandType;
import fmi.chesstern.controller.GameController;
import fmi.chesstern.game.GameState;
import fmi.chesstern.ui.GameUI;

public class DefaultGameController implements GameController {
	private GameState gameState;
	private GameUI ui;
	private GameCommandExecutor commandExecutor;
	
	public DefaultGameController(GameUI ui) {
		this.ui = ui;
		this.gameState = new GameState();
		
		DefaultGameCommandExecutor commandExecutor = new DefaultGameCommandExecutor(gameState);
		
		commandExecutor.registerCommand(GameCommandType.NEW_GAME, new DefaultNewGameHandler());
		commandExecutor.registerCommand(GameCommandType.MOVE, new DefaultMoveHandler());
		commandExecutor.registerCommand(GameCommandType.UNDO, new DefaultUndoHandler());
		commandExecutor.registerCommand(GameCommandType.EXIT, new DefaulExitHandler(ui));
		
		this.commandExecutor = commandExecutor;
	}
	
	public void start() {
		ui.start(commandExecutor, gameState);
	}
}
